package com.cqut.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.cqut.model.ProcessResultDetail;
import com.cqut.service.IProcessResultDetailService;
import com.cqut.dao.ProcessResultDetailMapper;
import com.cqut.util.SqlUtil;

@Service
public class ProcessResultDetailService implements IProcessResultDetailService {
    @Resource(name="processResultDetailMapper")
    private ProcessResultDetailMapper processResultDetailMapper;

    @Override
    public boolean save(ProcessResultDetail processResultDetail) {
        return processResultDetailMapper.insert(processResultDetail) > 0;
    }

    @Override
    public boolean update(ProcessResultDetail processResultDetail) {
        return processResultDetailMapper.updateByPrimaryKeySelective(processResultDetail) >= 0;
    }

    @Override
    public boolean delete(String processResultDetailId) {
        return processResultDetailMapper.deleteByPrimaryKey(processResultDetailId) > 0;
    }

    @Override
    public boolean batchDelete(String[] primaryKeys) {
        return processResultDetailMapper.deleteByPrimaryKeys(primaryKeys) > 0;
    }

    @Override
    public ProcessResultDetail findModel(String processResultDetailId) {
        return processResultDetailMapper.selectByPrimaryKey(processResultDetailId);
    }

    @Override
    public ProcessResultDetail findModel(String processResultDetailId, String[] parameters) {
        return processResultDetailMapper.findModel(processResultDetailId, SqlUtil.formatParameters(parameters));
    }

    public Map<String, Object> findMap(String processResultDetailId) {
        String[][] parameters = {{"process_result_detail_id", "processResultDetailId"}, {"process_detail_id", "processDetailId"}, {"file_review_time", "fileReviewTime"}};
        return this.findMap(processResultDetailId, parameters);
    }

    public Map<String, Object> findMap(String processResultDetailId, String[][] parameters) {
        return processResultDetailMapper.findMap(processResultDetailId, SqlUtil.formatParametersForAlias(parameters));
    }

    @Override
    public List<ProcessResultDetail> loadModels() {
        return this.loadModels(null, null, null, null, -1, -1);
    }

    @Override
    public List<ProcessResultDetail> loadModels(String condition, Object[] values, String order, String sort, int curPage, int limit) {
        return this.loadModels(null, condition, values, order, sort, curPage, limit);
    }

    @Override
    public List<ProcessResultDetail> loadModels(String[] parameters, String condition, Object[] values, String order, String sort, int curPage, int limit) {
        return processResultDetailMapper.loadModels(SqlUtil.formatParameters(parameters), SqlUtil.fillCondition(condition, values), order, sort, SqlUtil.getOffset(curPage, limit), limit);
    }

    @Override
    public List<Map<String, Object>> loadMaps() {
        String[][] parameters = {{"process_result_detail_id", "processResultDetailId"}, {"process_detail_id", "processDetailId"}, {"file_review_time", "fileReviewTime"}};
        return this.loadMaps(parameters, null, null, null, null, -1, -1);
    }

    @Override
    public List<Map<String, Object>> loadMaps(String condition, Object[] values, String order, String sort, int curPage, int limit) {
        String[][] parameters = {{"process_result_detail_id", "processResultDetailId"}, {"process_detail_id", "processDetailId"}, {"file_review_time", "fileReviewTime"}};
        return this.loadMaps(parameters, condition, values, order, sort, curPage, limit);
    }

    @Override
    public List<Map<String, Object>> loadMaps(String[][] parameters, String condition, Object[] values, String order, String sort, int curPage, int limit) {
        return processResultDetailMapper.loadMaps(SqlUtil.formatParametersForAlias(parameters), SqlUtil.fillCondition(condition, values), order, sort, SqlUtil.getOffset(curPage, limit), limit);
    }

    @Override
    public long count() {
        return this.count(null, false);
    }

    @Override
    public long count(String condition, Object[] values) {
        return this.count(null, condition, values, false);
    }

    @Override
    public long count(String[] parameters, boolean isDistinct) {
        return this.count(parameters, null, null, isDistinct);
    }

    @Override
    public long count(String[] parameters, String condition, Object[] values, boolean isDistinct) {
        return processResultDetailMapper.count(SqlUtil.formatParameters(parameters), SqlUtil.fillCondition(condition, values), isDistinct);
    }

}
